home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Stella Obscura 1.1 / source / Parts ƒ / SomeGlobals.p < prev    next >
Encoding:
Text File  |  1990-05-13  |  7.6 KB  |  207 lines  |  [TEXT/PJMM]

  1. unit SomeGlobals;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Sound;
  7.  
  8.     const
  9.         AppleM = 201;
  10.         GameM = 202;
  11.         OptionsM = 203;
  12.  
  13.         depth = 4;
  14.         sightDepth = 2;
  15.         flipSpeed = 2;
  16.         travelSpeed = 6;
  17.         nearest = 10;
  18.         farthest = 300;
  19.         hoopSize = 100;
  20.         farthestStray = 25;
  21.         numberOfEnemies = 3;
  22.  
  23.         leftWhole = 0;
  24.         rightWhole = 2;
  25.         leftNew = 1;
  26.         rightNew = 3;
  27.         currentPointer = 1;
  28.         dataDimension = 2;
  29.  
  30.     var
  31.         mainWndo: WindowPtr;
  32.  
  33.         offLeftVirginArea, offRightVirginArea, offLeftArea, offRightArea, offPlayerArea: Rect;
  34.         offLeftVirginMap, offRightVirginMap, offLeftMap, offRightMap, offPlayerMap: BitMap;
  35.         offLeftVirginPort, offRightVirginPort, offLeftPort, offRightPort, offPlayerPort: GrafPtr;
  36.         offLeftVirginBits, offRightVirginBits, offLeftBits, offRightBits, offPlayerBits: Ptr;
  37.  
  38.         playMask, idleMask: Integer;
  39.         leftScreenRgn, rightScreenRgn: RgnHandle;
  40.         bckgrndDst, bckgrndSrc, smallBckgrndSrc, leftBckgrndDst, rightBckgrndDst: Rect;
  41.  
  42.         enemiesPassed, enemyMax, enemyMaxCycles, enemySpeed: Integer;
  43.         enemyShot: array[1..numberOfEnemies] of Boolean;
  44.         enemySize: array[1..10, 1..49] of Integer;
  45.         enemySrc, enemyMaskSrc: array[0..8] of Rect;
  46.         theEnemies: array[1..10, 0..3, 1..49] of Rect;
  47.         enemyData: array[1..10, 1..49] of Integer;
  48.         currentEnemies: array[1..3, 1..2] of Integer;
  49.  
  50.     function DoRandom (range: Integer): Integer;
  51.     procedure IntroEffects;
  52.     procedure DoTheVirgin;
  53.  
  54. implementation
  55.  
  56. {=================================}
  57.  
  58.     function DoRandom;
  59.         var
  60.             rawResult: LongInt;
  61.     begin
  62.         rawResult := Abs(Random);
  63.         DoRandom := (rawResult * range) div 32768
  64.     end;
  65.  
  66. {=================================}
  67.  
  68.     procedure IntroEffects;
  69.         var
  70.             index: Integer;
  71.             dummyLong: LongInt;
  72.             tempSrc, tempMask, tempLeft, tempRight, wholeLeft, wholeRight, tempRect: Rect;
  73.     begin
  74.         CopyBits(offLeftVirginPort^.portBits, offLeftPort^.portBits, offLeftVirginMap.bounds, offLeftVirginMap.bounds, srcCopy, nil);
  75.         CopyBits(offRightVirginPort^.portBits, offRightPort^.portBits, offRightVirginMap.bounds, offRightVirginMap.bounds, srcCopy, nil);
  76.         CopyBits(offLeftPort^.portBits, mainWndo^.portBits, offLeftMap.bounds, leftBckgrndDst, srcCopy, nil);
  77.         CopyBits(offRightPort^.portBits, mainWndo^.portBits, offRightMap.bounds, rightBckgrndDst, srcCopy, nil);
  78.  
  79.         SetRect(tempSrc, 328, 103, 328 + 63, 103 + 35);
  80.         SetPort(offPlayerPort);
  81.         EraseRect(tempSrc);
  82.         SetRect(tempMask, 1, 264, 64, 299);
  83.         tempLeft := tempMask;
  84.         OffsetRect(tempLeft, -1, -264);
  85.         tempRight := tempLeft;
  86.         OffsetRect(tempLeft, 33, -36);
  87.         OffsetRect(tempRight, 31, -36);
  88.         for index := 1 to 100 do
  89.             begin
  90.                 wholeLeft := tempLeft;
  91.                 wholeLeft.top := wholeLeft.top - 1;
  92.                 wholeRight := tempRight;
  93.                 wholeRight.top := wholeRight.top - 1;
  94.                 CopyBits(offLeftVirginMap, offLeftMap, wholeLeft, wholeLeft, srcCopy, nil);
  95.                 CopyBits(offRightVirginMap, offRightMap, wholeRight, wholeRight, srcCopy, nil);
  96.                 CopyMask(offPlayerMap, offPlayerMap, offLeftMap, tempSrc, tempMask, tempLeft);
  97.                 CopyMask(offPlayerMap, offPlayerMap, offRightMap, tempSrc, tempMask, tempRight);
  98.                 tempRect := wholeLeft;
  99.                 OffsetRect(tempRect, 129, 50);
  100.                 CopyBits(offLeftMap, mainWndo^.portBits, wholeLeft, tempRect, srcCopy, leftScreenRgn);
  101.                 tempRect := wholeRight;
  102.                 OffsetRect(tempRect, 256, 50);
  103.                 CopyBits(offRightMap, mainWndo^.portBits, wholeRight, tempRect, srcCopy, rightScreenRgn);
  104.                 OffsetRect(tempLeft, 0, 1);
  105.                 OffsetRect(tempRight, 0, 1);
  106.             end;
  107.  
  108.         SetRect(tempSrc, 328, 103, 328 + 122, 103 + 67);
  109.         EraseRect(tempSrc);
  110.         SetRect(tempMask, 103, 255, 225, 322);
  111.         tempLeft := tempMask;
  112.         OffsetRect(tempLeft, -103, -255);
  113.         tempRight := tempLeft;
  114.         OffsetRect(tempLeft, 4, 241);
  115.         OffsetRect(tempRight, 0, 241);
  116.         for index := 1 to 130 do
  117.             begin
  118.                 wholeLeft := tempLeft;
  119.                 wholeLeft.bottom := wholeLeft.bottom + 1;
  120.                 wholeRight := tempRight;
  121.                 wholeRight.bottom := wholeRight.bottom + 1;
  122.                 CopyBits(offLeftVirginMap, offLeftMap, wholeLeft, wholeLeft, srcCopy, nil);
  123.                 CopyBits(offRightVirginMap, offRightMap, wholeRight, wholeRight, srcCopy, nil);
  124.                 CopyMask(offPlayerMap, offPlayerMap, offLeftMap, tempSrc, tempMask, tempLeft);
  125.                 CopyMask(offPlayerMap, offPlayerMap, offRightMap, tempSrc, tempMask, tempRight);
  126.                 tempRect := wholeLeft;
  127.                 OffsetRect(tempRect, 129, 50);
  128.                 CopyBits(offLeftMap, mainWndo^.portBits, wholeLeft, tempRect, srcCopy, leftScreenRgn);
  129.                 tempRect := wholeRight;
  130.                 OffsetRect(tempRect, 256, 50);
  131.                 CopyBits(offRightMap, mainWndo^.portBits, wholeRight, tempRect, srcCopy, rightScreenRgn);
  132.                 OffsetRect(tempLeft, 0, -1);
  133.                 OffsetRect(tempRight, 0, -1);
  134.             end;
  135.  
  136.         SetRect(tempSrc, 328, 103, 328 + 101, 103 + 22);
  137.         EraseRect(tempSrc);
  138.         SetRect(tempMask, 1, 300, 102, 322);
  139.         tempLeft := tempMask;
  140.         OffsetRect(tempLeft, -1, -300);
  141.         tempRight := tempLeft;
  142.         OffsetRect(tempLeft, 18, 241);
  143.         OffsetRect(tempRight, 8, 241);
  144.         for index := 1 to 40 do
  145.             begin
  146.                 wholeLeft := tempLeft;
  147.                 wholeLeft.bottom := wholeLeft.bottom + 1;
  148.                 wholeRight := tempRight;
  149.                 wholeRight.bottom := wholeRight.bottom + 1;
  150.                 CopyBits(offLeftVirginMap, offLeftMap, wholeLeft, wholeLeft, srcCopy, nil);
  151.                 CopyBits(offRightVirginMap, offRightMap, wholeRight, wholeRight, srcCopy, nil);
  152.                 CopyMask(offPlayerMap, offPlayerMap, offLeftMap, tempSrc, tempMask, tempLeft);
  153.                 CopyMask(offPlayerMap, offPlayerMap, offRightMap, tempSrc, tempMask, tempRight);
  154.                 tempRect := wholeLeft;
  155.                 OffsetRect(tempRect, 129, 50);
  156.                 CopyBits(offLeftMap, mainWndo^.portBits, wholeLeft, tempRect, srcCopy, leftScreenRgn);
  157.                 tempRect := wholeRight;
  158.                 OffsetRect(tempRect, 256, 50);
  159.                 CopyBits(offRightMap, mainWndo^.portBits, wholeRight, tempRect, srcCopy, rightScreenRgn);
  160.                 OffsetRect(tempLeft, 0, -1);
  161.                 OffsetRect(tempRight, 0, -1);
  162.             end;
  163.  
  164.         Delay(150, dummyLong);
  165.  
  166.         CopyBits(offLeftVirginMap, offLeftMap, offLeftVirginMap.bounds, offLeftVirginMap.bounds, srcCopy, nil);
  167.         CopyBits(offRightVirginMap, offRightMap, offRightVirginMap.bounds, offRightVirginMap.bounds, srcCopy, nil);
  168.         CopyBits(offLeftMap, mainWndo^.portBits, offLeftMap.bounds, leftBckgrndDst, srcCopy, nil);
  169.         CopyBits(offRightMap, mainWndo^.portBits, offRightMap.bounds, rightBckgrndDst, srcCopy, nil);
  170.     end;
  171.  
  172. {=================================}
  173.  
  174.     procedure DoTheVirgin;
  175.         var
  176.             tempRect, planetSrc, planetMask: Rect;
  177.     begin
  178.         CopyBits(offPlayerMap, offLeftVirginMap, smallBckGrndSrc, smallBckGrndSrc, srcCopy, nil);
  179.         tempRect := smallBckGrndSrc;
  180.         OffsetRect(tempRect, 127, 0);
  181.         CopyBits(offPlayerMap, offRightVirginMap, tempRect, smallBckGrndSrc, srcCopy, nil);
  182.  
  183.         SetRect(planetSrc, 256, 121, 287, 152);
  184.         SetRect(planetMask, 256, 153, 287, 184);
  185.         tempRect := planetSrc;
  186.         OffsetRect(tempRect, -256 + DoRandom(80), 60 + DoRandom(30));
  187.         CopyMask(offPlayerMap, offPlayerMap, offLeftVirginMap, planetSrc, planetMask, tempRect);
  188.         OffsetRect(tempRect, -2, 0);
  189.         CopyMask(offPlayerMap, offPlayerMap, offRightVirginMap, planetSrc, planetMask, tempRect);
  190.         SetRect(planetSrc, 288, 121, 298, 131);
  191.         SetRect(planetMask, 299, 121, 309, 131);
  192.         tempRect.right := tempRect.left + 10;
  193.         tempRect.bottom := tempRect.top + 10;
  194.         OffsetRect(tempRect, DoRandom(60) - 30, DoRandom(15));
  195.         CopyMask(offPlayerMap, offPlayerMap, offLeftVirginMap, planetSrc, planetMask, tempRect);
  196.         OffsetRect(tempRect, -4, 0);
  197.         CopyMask(offPlayerMap, offPlayerMap, offRightVirginMap, planetSrc, planetMask, tempRect);
  198.  
  199.         CopyBits(offLeftVirginMap, offLeftMap, offLeftVirginMap.bounds, offLeftVirginMap.bounds, srcCopy, nil);
  200.         CopyBits(offRightVirginMap, offRightMap, offRightVirginMap.bounds, offRightVirginMap.bounds, srcCopy, nil);
  201.         CopyBits(offLeftMap, mainWndo^.portBits, offLeftMap.bounds, leftBckgrndDst, srcCopy, nil);
  202.         CopyBits(offRightMap, mainWndo^.portBits, offRightMap.bounds, rightBckgrndDst, srcCopy, nil);
  203.     end;
  204.  
  205. {=================================}
  206.  
  207. end.